package homework;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class StudentTest {
    public static void main(String[] args) {
        HashMap<Student, String> studentStringHashMap = new HashMap<>();


        studentStringHashMap.put(new Student(),"123");

        //方式一：获取Map集合中所有的key并组成Set视图
        Set<Student> students = studentStringHashMap.keySet();
        //遍历所有的key
        for (Student ss:students) {
            System.out.println(ss + "::" +studentStringHashMap.get(ss));
        }

        //方式二：获取Map集合中所有的键值对并组成Set视图
        Set<Map.Entry<Student, String>> entries = studentStringHashMap.entrySet();
        for (Map.Entry<Student, String> sst:entries) {
            System.out.println(sst.getKey()+"::" + sst.getValue());
        }


    }
}
